<%@ page import="entity.User" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="common/tag.jsp" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <title>文章编辑器</title>
    <%--    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">--%>
    <%--    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->--%>
<%--    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>--%>
    <%--    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->--%>
    <%--    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>--%>


    <link rel="stylesheet" href="${pageContext.request.contextPath}/resource/css/to-do.css">
    <!-- Custom Theme files -->
    <link href="https://cdn.bootcss.com/twitter-bootstrap/4.2.1/css/bootstrap.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/resource/css/style2.css" rel="stylesheet" type="text/css"
          media="all"/>


    <!-- Custom Theme files -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <style>
        .form-group {
            border: 1px solid #F2F3F6;
            display: inline-block;
            width: 80%;
            margin-bottom: 0;
        }

        .form-group label {
            line-height: 34px;
            width: 6%;
            float: left;
            padding-left: 5px;
            margin-bottom: 0;
        }

        .form-group input, .form-group input:focus {
            border: none;
            padding: 0;
            width: 80%;
            float: left;
            height: 6%;
        }

        h4 {
            font-size: 24px;
            color: #a2a2a2;
            font-weight: 300;
        }

        .btn-theme {
            color: #fff;
            background-color: #4ECDC4;
            border-color: #48bcb4;
        }

        ul.top-menu > li > .logout {
            color: #f2f2f2;
            font-size: 12px;
            border-radius: 4px;
            -webkit-border-radius: 4px;
            border: 1px solid #64c3c2 !important;
            padding: 5px 15px;
            margin-right: 15px;
            background: #4ECDC4;
            margin-top: 15px;
        }
    </style>
</head>
<body>

<jsp:include page="common/head1.jsp"/>

<div class="col-md-4 right_column" style="margin-left: 60px">
    <div class="item2">

        <ul style="list-style: none">
            <c:if test='${sessionScope.user.userType==2}'>
                <li style="float: left"><a href="${pageContext.request.contextPath}/new/adminIndex.html">管理首页</a></li>
            </c:if>
            <c:if test='${sessionScope.user.userType==0||sessionScope.user.userType==1}'>
                <li style="float: left"><a href="${pageContext.request.contextPath}/user/index.html">首页</a></li>
                <li style="float: left"><a href="${pageContext.request.contextPath}/user/center.html">我发表的文章和评论</a></li>
            </c:if>

            <%--            <li style="float: left"><a href="#">我发表的文章和评论</a></li>--%>
        </ul>
    </div>
</div>
<div class="clearfix"></div>


<h4 style="margin-left: 100px;margin-top: 10px">${title}插入新闻</h4>

<div style="margin-left: 100px;margin-right: 100px;margin-top:50px;margin-bottom: 200px">
    <%
        User user = (User) session.getAttribute("user");
    %>

    <span>${insertNewResult.errMes}</span>

    <form id="articleForm" action="${pageContext.request.contextPath}/new/submitContent" method="post">

        <div class="form-group">
            <label for="to" class="">标 题:</label>
            <input type="text" name="title" tabindex="1" id="to" class="form-control">
        </div>
        <div class="form-group">
            <label for="category" class="">类 型:</label>
            <%--            <input type="text"  name="categoryId" tabindex="1" id="category" class="form-control" onchange="checktype()">--%>
            <%--            <span id="tip_category" style="color: rebeccapurple"></span>--%>
            <select id="category" name="categoryId" class="form-control" style="width: auto">

                <option value="1" selected>热点</option>
                <option value="2">娱乐</option>
                <option value="3">科技</option>
                <option value="4">军事</option>
                <option value="5">体育</option>
                <option value="6">国际</option>
            </select>

        </div>
        <div class="form-group">
            <label for="do" class="">关键字:</label>
            <input type="text" name="keyWords" tabindex="1" id="do" class="form-control">
        </div>
        <!-- 加载编辑器的容器 -->
        <script id="container" name="content" type="text/plain">
        </script>

        <input type="hidden" id="summary" name="summary"/>

        <button class="btn-theme" id="submit" type="submit" onclick="setSummaryValue()"><i class="fa fa-lock"></i>提 交
        </button>
    </form>
</div>
<%--<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>--%>
<!-- 配置文件 -->
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/ueditor/ueditor.all.js"></script>

<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('container');

    $(function () {
        $('#articleForm').on('submit', function () {
            setSummaryValue();
        });
    });


    function setSummaryValue() {
        // alert(ue.getContentTxt());
        $("#summary").attr("value", ue.getContentTxt());

    }


    // document.getElementById("summary").innerText=ue.getContentTxt();

    // alert(ue.getContentTxt());

    function checktype() {
        username = document.getElementById("category");
        tip = document.getElementById("tip_category");
        reg = /^[1-6]{1}$/;

        if (!reg.test(username.value)) {
            tip.innerHTML = "请输入数字代表类型：1:热点 2:娱乐 3:科技 4:军事 5:体育 6:国际";
            return false;
        } else {
            tip.innerHTML = " ";
            return true;
        }
    }
</script>


</body>
</html>
